function Agg=Aggregation(PP,SS,QW_fz,DistPolicy,UnitTrMat)

% DistPolicy_V=   SS.DistPolicy.V;
% DistPolicy_Vhat=SS.DistPolicy.Vhat;
% QW_fzo      =   SS.Dist_fzo.QW_fzo;
% DistPolicy    =   SS.DistPolicy;
% UnitTrMat       =   SS.TrProb.UnitTrMat;
%% Preliminaries
QW          =   UnitTrMat.ReEval*QW_fz;
QW_V        =   (1-PP.XI)*QW;
QW_Vhat     =   PP.XI*QW;

f           =   SS.DistApp.fz.State(:,1);
ID          =   SS.DistApp.fz.State(:,2);
N_State     =   size(ID,1);

Mid_f       =   max(SS.DistApp.fz.UnitNode{1}(cumsum(SS.Dist_fz.Marginal_fz.f)<0.5));

Ind         =   struct();


Ind.rich    =   f>Mid_f;
Ind.poor    =   f<=Mid_f;

GroupList   =   {{'rich'},{'poor'}};
%% Aggregation
% Weighted Policies
AggVarList  =   {'c','l','b','FC','fp','zl','UI'};
for ii=1:length(AggVarList)
    vv              =   AggVarList{ii};
    QWQQ.V.(vv)     =   DistPolicy.V.(vv).*QW_V;
    QWQQ.Vhat.(vv)  =   DistPolicy.Vhat.(vv).*QW_Vhat;
end

QWQQ.V.f    =   f.*QW_V;
QWQQ.Vhat.f =   f.*QW_Vhat;
% Aggregated Policies
AggVarList  =   {'f','c','l','b','FC','fp','zl','UI'};
Tot         =   struct();
Avg         =   struct();
Prob        =   struct();
for ii=1:length(GroupList)
    TempGroup   =   GroupList{ii};
    TempLabel   =   strjoin(TempGroup,'_');
    for jj=1:length(TempGroup)
        if jj==1
            TempInd     =   Ind.(TempGroup{jj});
        else
            TempInd     =   TempInd & Ind.(TempGroup{jj});
        end
    end
    Prob.(TempLabel) ...
                =   ( sum(QW_V(TempInd))+sum(QW_Vhat(TempInd)) );
    for jj=1:length(AggVarList)
        vv      =   AggVarList{jj};
        Tot.(vv).(TempLabel) ...
                =   sum(QWQQ.V.(vv)(TempInd))+sum(QWQQ.Vhat.(vv)(TempInd));
        Avg.(vv).(TempLabel) ...
                =   Tot.(vv).(TempLabel)/Prob.(TempLabel);
    end
end

C           =   Tot.c.rich+Tot.c.poor;

% Labor Supply
L           =   Tot.zl.rich+Tot.zl.poor;
% Total Saving
B           =   Tot.fp.rich+Tot.fp.poor;

% Total Financial Service Cost
FC          =   Tot.FC.rich+Tot.FC.poor;

% Total UI Required
UI          =   Tot.UI.rich+Tot.UI.poor;

Agg         =   struct('Tot',Tot,'Avg',Avg,'Prob',Prob, ...
                       'C',C,'L',L,'B',B,'FC',FC,'UI',UI);